/* TotalDcmListerPluginView.h -- Header file for class TotalDcmListerPluginView
*
* TotalDcmLister - A lister plugin for Total Commander for listing DICOM File content.
*
* Copyright (C) 2015 Captain Stark
*
* This software may be modified and distributed under the terms of the MIT license.
* See the COPYRIGHT file at the top-level directory of this distribution for details.
*/

#pragma once

#include "resource.h"
#include "afxcmn.h"
#include "afxwin.h"

#include <string>

using namespace std;

/// <summary>
/// Defines the Total DICOM Lister plugin's view.
/// </summary>
class TotalDcmListerPluginView : public CDialogEx
{
   DECLARE_DYNAMIC(TotalDcmListerPluginView)

public:
   /// <summary>
   /// Initializes a new instance of the <see cref="TotalDcmListerPluginView"/> class.
   /// </summary>
   /// <param name="pParent">The parent window.</param>
   TotalDcmListerPluginView(CWnd* pParent = NULL);

   /// <summary>
   /// Finalizes an instance of the <see cref="TotalDcmListerPluginView"/> class.
   /// </summary>
   virtual ~TotalDcmListerPluginView();

   /// <summary>
   /// Called in response to the WM_INITDIALOG message.
   /// </summary>
   /// <returns>True, when input focus is set to one of the controls in the dialog box. False otherwise.</returns>
   BOOL OnInitDialog();

   /// <summary>
   /// Sets the header text.
   /// </summary>
   /// <param name="text">The text.</param>
   void SetHeaderText(const wstring& text);

   /// <summary>
   /// Adds a group to the DICOM attribute list view.
   /// </summary>
   /// <param name="groupId">The group identifier.</param>
   /// <param name="groupHeader">The group header.</param>
   void AddListViewGroup(const int groupId, const wstring& groupHeader);

   /// <summary>
   /// Adds an item to the DICOM attribute list.
   /// </summary>
   /// <param name="groupId">The group identifier.</param>
   /// <param name="attributeText">The attribute text.</param>
   /// <param name="valueText">The value text.</param>
   void AddListViewItem(const int groupId, const wstring& attributeText, const wstring& valueText);

   enum { IDD = IDD_PLUGINVIEW };

protected:
   /// <summary>
   /// Does the dialog data exchange.
   /// </summary>
   /// <param name="pDX">A pointer to a CDataExchange object.</param>
   virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

   /// <summary>
   /// Called after the window's size has changed.
   /// </summary>
   /// <param name="nType">The type of resizing requested.</param>
   /// <param name="width">The new width of the client area.</param>
   /// <param name="height">The new height of the client area.</param>
   afx_msg void OnSize(UINT nType, int width, int height);

   /// <summary>
   /// Called by the framework when a child control is about to be drawn.
   /// </summary>
   /// <param name="pDC">Contains a pointer to the display context for the child window. May be temporary.</param>
   /// <param name="pWnd">Contains a pointer to the control asking for the color. May be temporary.</param>
   /// <param name="nCtlColor">Specifying the type of control.</param>
   /// <returns>A handle to the brush that is to be used for painting the control background.</returns>
   afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);

   /// <summary>
   /// Called when 'About' button was clicked. Opens a simple about dialog.
   /// </summary>
   afx_msg void OnBnClickedAboutbutton();

   DECLARE_MESSAGE_MAP()

private:
   CFont m_fontHeader;
   CStatic m_ctrlHeader;
   CButton m_ctrlAboutButton;
   CListCtrl m_ctrlDicomAttributeList;

   /// <summary>
   /// Sets up the visual appearance of static header control. 
   /// </summary>
   void SetupHeader();
      
   /// <summary>
   /// Sets up the DICOM attribute list view.
   /// Includes 2 columns, one for the DICOM Attribute name, one for the value.
   /// </summary>
   void SetupListView();


   /// <summary>
   /// Called when the DICOM attribute list control received a WM_KEYDOWN message.
   /// If ESCAPE key was pressed it's essential to let the plugin parent know this.
   /// </summary>
   /// <param name="id">The identifier of the sender.</param>
   /// <param name="pNotifyStruct">Pointer to an NMLVKEYDOWN structure.</param>
   /// <param name="pResult">The result.</param>
   /// <returns>
   /// TRUE when message has been handled, FALSE otherwise.
   /// </returns>
   afx_msg BOOL OnKeydownInDicomAttributeList(UINT id, NMHDR * pNotifyStruct, LRESULT *pResult);
};
